-module(resources_controller).

-export([
	index/1
]).


index(A) ->
	Appmod = yaws_arg:appmoddata(A),
	Path = string:tokens(Appmod, "/"),
	Length = length(Path),
	if 
		 Length >= 3 ->
			Action = lists:nth(3, Path),
			
			%% we need to preview stuff we've written in edit/create/discuss
			Cond = Action == "edit" orelse Action == "create" orelse Action == "discuss",
			case Cond of
				true ->
					{data, [
						{javascript_raw, "
							wmd_options = { 
								autostart: false, 
								output: \"Markdown\",
								// line wrapping length for lists, blockquotes, etc.
								lineLength: 80
							};
						"},
						{javascript, "wmd/showdown"},
						{javascript, "wmd/wmd-base"},
						{javascript, "wmd/wmd-plus"},
						{javascript, "wmd/wmd"},
						{javascript, "preview"}
					]};
				_ ->
					{data, []}
			end;
		true ->
			{data, []}
	end.
    